<template>
  <div class="index bgf5f6 h100p">
    <div>
      <div v-if="card_msg.style == 0">
        <Card_1 :card_msg="card_msg"></Card_1>
      </div>

      <div v-if="card_msg.style == 1">
        <Card_2 :card_msg="card_msg" @uploadpic="uploadpic"></Card_2>
      </div>

      <div v-if="card_msg.style == 2">
        <Card_3 :card_msg="card_msg"></Card_3>
      </div>

      <div v-if="card_msg.style == 3">
        <Card_4 :card_msg="card_msg"></Card_4>
      </div>

      <!--2.0-->
      <Card_5 v-if="card_msg.style == 4" :card_msg="card_msg"></Card_5>
      <Card_6 v-if="card_msg.style == 5" :card_msg="card_msg"></Card_6>
      <Card_7 v-if="card_msg.style == 6" :card_msg="card_msg"></Card_7>
    </div>

    <!--    <div class="pt15 pl16 pr15 pt16 bgfff pb15">-->
    <!--      <div class="top_card fs12 shadow_gray pb40">-->
    <!--        <div class="pl34 pt25 cblue fs12"><span class="before_line_3">{{card_msg.companyName}}</span></div>-->
    <!--        <div class="top_msg disflex jsbet pt40">-->
    <!--          <div>-->
    <!--            <p class="fbold c38 fs18">{{card_msg.name}}</p>-->
    <!--            <p class="fs14 ca8 pt10 pb23">{{card_msg.position || '职位'}}</p>-->
    <!--            <p class="fs12 c78">» {{card_msg.phone || '电话'}}</p>-->
    <!--            <p class="fs12 c78">» {{card_msg.email || '邮箱'}}</p>-->
    <!--          </div>-->

    <!--          <img :src="card_msg.logo || 'https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/card1_user.png'"-->
    <!--               mode="aspectFill"-->
    <!--               alt="" class="w60 h60 bradius5" />-->

    <!--        </div>-->
    <!--      </div>-->
    <!--    </div>-->

    <!-- <div class="disflex pl15 pr15 fs18 lh44 textc jsbet bgfff" v-if="card_msg.cardId">
      <div class="bblue cblue  bradius5 w165" @click="toRoute('editCard','?type=edit')">
        编辑名片
      </div> -->
    <!-- <div class="bgblue bradius5 cfff w165">
           发送名片
       </div>-->
    <!-- <button class='bgblue bradius5 cfff w165 mr0' open-type="share" hover-class="other-button-hover">
        发送名片
      </button>
    </div>

    <div class="bgfff pl43 pr43" v-else>
      <span class="disinblock bradius5 bg_line_blue textc cfff w290 fs18 lh44" @click="toCreatePage">创建我的名片</span>
    </div> -->

    <view>
      <div class="card_menu fs12 ca8 bgfff borderbox pl10">
        <div class="clearfix pt5 pb5 disflex operation-box">
          <div class="shadow_gray h65 mr10 business_card" @click="createCode">
            <img :src="cardCodeImg" alt="" class="w65 h65">
          </div>
          <scroll-view scroll-x scroll-with-animation>
            <div class="disflex scroll-list">
              <div class="shadow_gray textc pt15 pl15 pr15 h65 mr10" @click="toRoute('showBill', '?cardId='+currentCompany.cardId)">
                <p class="pb7">
                  名片海报
                </p>
                <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/wx_timeline.png" alt=" "
                  class="w20 h20" />

              </div>
              <div class="shadow_gray textc pt15 pl15 pr15 h65 mr10" @click="tel">
                <p class="disflex align-cen">
                  <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/tel_2.png" alt="" class="w16 h16" />
                  <span class="pl9">拨打电话</span>
                </p>
                <p class="c78 fbold pt7">{{card_msg.phone || '未填写'}}</p>
              </div>
              <div class="shadow_gray textc pt15 pl15 pr15 h65 mr10" @click="addWx">
                <p class="disflex align-cen">
                  <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/im_msg.png" alt="" class="w16 h16" />
                  <span class="pl9">添加微信</span>
                </p>
                <p class="c78 fbold pt7">{{card_msg.personalWx || '未填写'}}</p>
              </div>
              <div class="shadow_gray textc pt15 pl15 pr15 h65 mr10" @click="openAddr(card_msg.address)">
                <p class="disflex align-cen">
                  <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/product-index/20190425164542.png" alt=""
                    class="w16 h16" />
                  <span class="pl9">公司地址</span>
                </p>
                <p class="c78 fbold pt7">{{card_msg.address || '未填写'}}</p>
              </div>
            </div>
          </scroll-view>
        </div>
        <div class="more-info">
          <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/product-index/20190514143457.png" alt="" class="left-img">
        </div>
      </div>

    </view>
    <div class="seen_peo disflex pl15 pr26 fs10 pb20 ca8 jsbet bgfff">
      <span class="seen_peo_dot" v-if="todayNumber"></span>
      <div class="disflex">
        <div class="disflex">
          <div class="browsing-history" :style="{zIndex:100 - k}" v-for="(v,k) in card_msg.browsePhoto" :key="k">
            <img :src="v" alt mode="aspectFill" class="w30 h30 b6fff bradius50p shadow_grayA" />
          </div>

        </div>
        <div class="ml21 newNub">
          <p class="newl-added" v-if="dayBrowseNum">今日+{{dayBrowseNum}}</p>
          <p class="lh20 fs14 fbold c38">{{card_msg.browseNum ? card_msg.browseNum : 0}}</p>
          <p class="fs12 ca8">浏览量</p>
        </div>
      </div>
      <view>
        <div class="disflex fs18 lh44 textc jsbet bgfff user-btn-group">
          <!-- <div>
              <button class="share_card w165 bradius5 cblue bblue bgfff"
                      open-type="share"
                      hover-class="other-button-hover"
                      style="margin: 0">
                分享名片
              </button>
            </div> -->
          <div v-if="card_msg.cardId" class="disflex shadow_grayB bgblue jscen align-cen borderbox bradius44 cfff w165 edit-btn"
            @click="toRoute('editCard','?type=edit')" style="margin: 0">
            <img class="w20 h20 mr10" :src="editIcon">
            <P class="lhno">编辑名片</P>
          </div>
          <div v-else class="posre bgblue bradius44 cfff w165 flex-c-c create-card" style="margin: 0">
            <div class="share_card borderbox w165 bradius44 cfff bgblue" @click="toCreatePage">

              创建名片
            </div>
          </div>
        </div>
      </view>

    </div>

    <div class="disflex bgfff forward align-cen pb12 jsbet">
      <div>
        <button open-type="share" hover-class="other-button-hover" class="disflex bgfff align-cen flex-column">
          <div class="disflex w44 mb12 h44 align-cen jscen bradius50p shadow_grayA">
            <img :src="weixinIcon" class="w25 h25">
          </div>
          <p class="fs14 fbold lh1">转发名片</p>
        </button>
      </div>
      <div class="disflex align-cen flex-column" @click="doThumbs">
        <div class="disflex w44 h44  mb12 align-cen jscen bradius50p shadow_grayA">
          <img :src="isThumbs ? isLikeIcon: likeIcon" class="w25 h25">
        </div>
        <p class="fs14 fbold lh1">靠谱<span class="cblue">{{card_msg.thumbsNum || 0}}</span></p>
      </div>
    </div>
    <!-- <div class="seen_peo disflex pl15 pr26 fs10 ca8 pb15 jsbet bgfff">
      <div>
        <div class="disflex">
          <img v-for="(v,k) in card_msg.browsePhoto" :key="k" :src="v" alt=""
               mode="aspectFill"
               class="w20 h20 bradius3 mr3"
          >
        </div>
        <p class="lh20">
          已有{{card_msg.browseNum ? card_msg.browseNum : 0}}人浏览
        </p>
      </div>
      <div class="textc">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/like.png"
             alt=""
             :class="isThumbs ? 'w20 h20' : 'filter_gray w20 h20'"
        />
        <p>靠谱 <span class="cpurple">{{card_msg.thumbsNum}}</span></p>
      </div>
    </div> -->
    <!--全员营销-->
    <div class="marketing" @click="toMarketing">
      <image src="http://test1.mingyicloud.com/uploads/20210316/2f596c9024b5e2112535055f120883b9.png"></image>
      <!-- <image src="../../static/images/fillet.png"></image> -->
    </div>
    <div class="bgfff pl15 pr15 pt20 pb20 mb10 ">
      <div class="degree-of-perfection" style="display: none;">
        <div class="perfection c38 fs14 mb10">
          名片完善度
          <span class="fs18 fbold">{{card_msg.perfectRate || 0}}%</span>
          超越
          <span class="fs18 fbold">{{card_msg.perfectRateRank || 0}}%</span>
          同行
          <span class="fs18 cblue floatr" @click="toRoute('editCard','?type=edit')">去完善</span>
        </div>
        <div class="desc ca8 fs12">
          提高名片的完善度能更好地推广您的名片哦
        </div>
        <div class="line-outer">
          <div class="line" :style="'width: '+card_msg.perfectRate + '%'"></div>
        </div>
      </div>
      <view>
          <view style="background-image: linear-gradient(to right, #FFA340 ,#FBC94A);height:280rpx;border-radius:10rpx;color:#fff;padding-top:40rpx;padding-left:40rpx;padding-right:40rpx;">
              <view style="margin-bottom: 10rpx;">总金额</view>
               <view style="font-size: 72rpx;letter-spacing: 10rpx;font-weight: bold;margin-bottom:;">{{accountAmount || 0.00}}</view>
               <view style="display:flex;justify-content: space-between;padding-botom:40rpx;box-sizing: border-box;">
                   <view style="width: 100%;display: flex;justify-content: space-between;flex-direction: column;">
                     <view style="width: 100%;">
                       冻结金额
                     </view>
                     <view style="width: 100%;">
                       {{freezeAmount || 0.00}} ￥
                     </view>
                   </view>

                   <view style="width: 100%;box-sizing: border-box;border-left:1rpx solid  #fff;padding-left:40rpx;display: flex;justify-content: space-between;flex-direction: column;">
                      <view style="width: 100%;">
                        可用余额
                      </view>
                      <view style="width: 100%;">
                        {{usableAmount || 0.00}} ￥
                      </view>
                   </view>
               </view>
          </view>

      </view>
      <!-- <div class="disflex jsbet wrap textc pt20">
        <div class="w108 h108 be8 bradius3 textc disflex align-cen borderbox">
          <div class="w100p">
            <p class="fs12 ca8 pb7">总金额</p>
            <p class="fs18 c38 fbold">{{accountAmount || 0}}</p>
          </div>
        </div>

        <div class="w108 h108 be8 bradius3 textc disflex align-cen borderbox">
          <div class="w100p">
            <p class="fs12 ca8 pb7">可用余额</p>
            <p class="fs18 c38 fbold">{{usableAmount || 0}}</p>
          </div>
        </div>

        <div class="w108 h108 be8 bradius3 textc disflex align-cen borderbox">
          <div class="w100p">
            <p class="fs12 ca8 pb7">冻结金额</p>
            <p class="fs18 fbold">{{freezeAmount || 0}}</p>
          </div>
        </div>
      </div> -->
      <!-- <div class="disflex jsbet wrap textc pt20">
        <div class="w108 h108 be8 bradius3 textc disflex align-cen borderbox">
          <div class="w100p">
            <p class="fs12 ca8 pb7">昨日获客</p>
            <p class="fs18 c38 fbold">{{card_msg.yesterdayCustomerCount || 0}}</p>
          </div>
        </div>

        <div class="w108 h108 be8 bradius3 textc disflex align-cen borderbox">
          <div class="w100p">
            <p class="fs12 ca8 pb7">昨日浏览</p>
            <p class="fs18 c38 fbold">{{card_msg.yesterdaySeeCount || 0}}</p>
          </div>
        </div>

        <div class="w108 h108 be8 bradius3 textc disflex align-cen borderbox">
          <div class="w100p">
            <p class="fs12 ca8 pb7">昨日订单</p>
            <p class="fs18 fbold">{{card_msg.yesterdayOrderCount || 0}}</p>
          </div>
        </div>
      </div> -->
    </div>

    <div class="bgfff disflex jsbet pl33 pr26 pt20 mt10 mb10 textc">
      <div @click="toCardCase">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/cardcase.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">名片夹</p>
      </div>
      <div @click="toFrequent">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com//one-www/photo/20190529/1559095573730.png" alt=""
          class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">常用功能</p>
      </div>
      <div @click="makeWx">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/im_msg.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">我要合作</p>
      </div>
      <div @click="makePhone">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/kefu.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">我的客服</p>
      </div>
    </div>

    <div class="bgfff disflex jsbet pl33 pr26 pt20 mt10 mb10 textc">

      <div @click="myshare">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com//one-www/photo/20190529/1559095573730.png" alt=""
          class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">分享记录</p>
      </div>

      <div @click="myPrecise">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/cardcase.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">精准转发</p>
      </div>

      <div @click="toMyPushEffect">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/im_msg.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">推效记录</p>
      </div>

      <div @click="toAward">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/im_msg.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">钱包</p>
      </div>
    </div>

    <div class="bgfff disflex jsbet pl33 pr26 pt20 mt10 mb10 textc">
      <!--封：20210224 start-zlz -->
      <div @click="toMyCard">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/cardcase.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">切换名片</p>
      </div>
      <!--封：20210224 end-zlz -->
      <!-- <div @click="toFollowRecord">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/cardcase.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">线上跟进记录</p>
      </div> -->
      <div @click="balance">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/cardcase.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">余额充值</p>
      </div>
      <div @click="visit">
        <img src="https://myy-one-stand.oss-cn-beijing.aliyuncs.com/yimai_photos/crm/cardcase.png" alt="" class="w30 h30" />
        <p class="fs12 c78 pt10 pb20">拜访记录</p>
      </div>
    </div>

    <!--未创建名片提示-->
    <div v-show="nocard_show">
      <DialogBox :dialog_title="'提示'" @btn_tap="nocard_btn_tap" :dialog_ph="'您还没有名片哦，请先创建自己的名片再进入'" :type="'hint2'"
        :left="'取消'" :right="'创建名片'"></DialogBox>
    </div>

    <div v-if="isShowCourse">
      <addWxCourse :isShow="isShowCourse" @close="isShowCourse=false" />
    </div>

    <!-- https://blog.csdn.net/chaosama/article/details/101704260 -->

        <view class='toast-box' v-if="isShowConfirm">
          <view class='toastbg'></view>
          <view class='showToast'>
              <view class='toast-title'>
                  <text>输入充值金额</text>
              </view>
              <view class='toast-main'>
                  <view class='toast-input'>
                      <input type='number' @click='setValue' v-model="money"></input>
                  </view>
              </view>
              <view class='toast-button'>
                  <view class='button1'>
                      <button @click='cancel'>取消</button>
                  </view>
                  <view class='button2'>
                      <button data-url="../allOrder/allOrder" @click='confirmAcceptance'>确定</button>
                  </view>
              </view>
          </view>
      </view>
  </div>


</template>

<script>
  import DialogBox from '@/components/dialogBox' // 对话框
  import StaticResources from '@/components/StaticResources';
  import AddWxCourse from '@/components/addWxCourse'
  import Card_1 from '@/components/card_1' //
  import Card_2 from '@/components/card_2' //
  import Card_3 from '@/components/card_3' //
  import Card_4 from '@/components/card_4' //
  import Card_5 from "@/components/card_5"; //
  import Card_6 from "@/components/card_6"; //
  import Card_7 from "@/components/card_7"; //

  import util from '../../utils/index'
  import WXAJAX from '../../utils/request';
  import {
    mapActions,
    mapGetters
  } from 'vuex';
  import {
    authSubscribeMessage,
    authSubscribeOrder
  } from '../../utils/auth.js'

  export default {
    data() {
      return {
        hasCard: true, //是否已经有自己的名片
        nocard_show: false,
        COMPANYID: 0,
        CARDID: 0,
        isShowConfirm:false,
        money:'',
        card_msg: {
          style: 0,
          cardId: ''
        },
        isThumbs: 0, //是否点赞
        isShowCourse: false,
        card_style: 0,
        cardCodeImg: WXAJAX.imgBackUrl + 'yimai_photos/crmRevision/img_card_code.png',
        saveIcon: WXAJAX.imgBackUrl + 'yimai_photos/crmRevision/icon_save.png',
        weixinIcon: WXAJAX.imgBackUrl + 'yimai_photos/crmRevision/ic_weixin.png',
        likeIcon: WXAJAX.imgBackUrl + 'yimai_photos/crmRevision/ic_like.png',
        isLikeIcon: WXAJAX.imgBackUrl + 'yimai_photos/crmRevision/ic_select_like.png',
        editIcon: WXAJAX.imgBackUrl + 'yimai_photos/crmRevision/icon_ edit.png',
        firstLoginIcon: WXAJAX.imgBackUrl + 'yimai_photos/crmRevision/img_viewmore.png',
        companyId: '',
        cardId: '',
        accountAmount:0,
        freezeAmount:0,
        usableAmount:0
      }
    },

    components: {
      DialogBox,
      AddWxCourse,
      StaticResources,
      Card_1,
      Card_2,
      Card_3,
      Card_4,
      Card_5,
      Card_6,
      Card_7
    },

    created() {
      wx.setNavigationBarTitle({
        title: "我的"
      });
      this.COMPANYID = this.currentCompany.companyId;
      this.CARDID = this.currentCompany.cardId;
      // this.inits();
    },
    /** tab点击 */
    onTabItemTap(item) {
      //订阅授权 信息相关
      authSubscribeMessage(this.subscriptionNew);
    },
    onShow() {

      this.money='';
      if (!this.COMPANYID) {
        this.COMPANYID = this.currentCompany.companyId;
        this.CARDID = this.currentCompany.cardId;
      }
      this.inits();
      wx.showShareMenu({
        withShareTicket: true,
        menus: ['shareAppMessage', 'shareTimeline']
      })

      //获取钱包数据
      let that=this;
      WXAJAX.POST({
        ignore: true
      }, '', '/account/myAccount', '', '', 1).then((data) => {
        that.accountAmount=data.accountAmount;
        that.freezeAmount=data.freezeAmount;
        that.usableAmount=data.usableAmount;
      });

    },
    async onPullDownRefresh() {
      // to doing..
      // 停止下拉刷新
      wx.showNavigationBarLoading();
      this.inits();
      wx.stopPullDownRefresh();
      setTimeout(function() {
        wx.hideNavigationBarLoading();
      }, 300)
    },
    onShareAppMessage() {
      const {
        cardId,
        companyName,
        name,
        position,
        shareSpeech
      } = this.currentCompany;
      let shareMessage = "";
      if (shareSpeech && typeof(shareSpeech) === "string") {
        shareMessage = shareSpeech.replace('#name#', name).replace('#company#', companyName);
      }
      return {
        title: shareMessage || `您好，我是${companyName}的${position || ''}${name}，敬请惠存!`,
        path: `/pages/shareCard/main?cardId=${cardId}`,
        success(e) {
          console.log(e)
        },
        fail(e) {
          console.log('失败-- ', e);
        }
      }
    },
    onShareTimeline() {
      //分享朋友圈
    },
    methods: {
      ...mapActions(['setCurrentCompany']),

      toCardCase() {
        let cardId = wx.getStorageSync("userId");
        // let cardId = wx.setStorageSync("userId");
        authSubscribeMessage(this.subscriptionNew);
        // wx.navigateTo({
        //   url: "/pages/mycard/main"
        // });
        util.toMiniProgram(`/pages/cardCase/main?goType=1`, '', this.cardId, this.companyId);
      },
      toMyCard() {
        wx.navigateTo({
          url: "/pages/mycard/main"
        });
      },
      toFollowRecord(){
        wx.navigateTo({
          url: "/pages/followrecord/main"
        });
      },
      toFrequent() {
        authSubscribeMessage(this.subscriptionNew);
        if (!this.card_msg.cardId) {
          this.nocard_show = true;
        } else {
          wx.navigateTo({
            url: "/pages/frequentPack/frequent/main"
          });
        }
      },

      makePhone() {
        authSubscribeMessage(this.subscriptionNew);
        return WXAJAX.POST({
          ignore: true
        }, '', '/company/selectWebsiteInfo').then((data) => {
          if (data && data.phone) {
            //查询机构电话
            wx.makePhoneCall({
              phoneNumber: data.phone,
            })
          } else {
            wx.showToast({
              title: '请设置机构电话'
            })
          }
        }).catch((err) => {
          console.log("数据请求失败")
        })
      },
      myPrecise() {
        authSubscribeMessage(this.subscriptionNew);
        wx.navigateTo({
          url: "../companyPack/myPrecise/main"
        });
      },
      setValue() {
          // console.log(this.money);
      },
      cancel(){
        this.isShowConfirm=false
        console.log(this.money);
      },
      confirmAcceptance(){
        // this.topay();
        this.isShowConfirm=false;
        let that=this;
        WXAJAX.POST({
          accountAmount: this.money,
          usableAmount: this.money,
        }, '', '/account/updateAccountByAccountId','','',1).then((data, code) => {
          WXAJAX.POST({
            ignore: true
          }, '', '/account/myAccount', '', '', 1).then((data) => {
            that.money='';
            that.accountAmount=data.accountAmount;
            console.log(data.accountAmount,111)
            that.freezeAmount=data.freezeAmount;
            that.usableAmount=data.usableAmount;
          });
        });


      },
      topay(){//充值
        let than = this
        let data = {
          payUserId:7010,
          companyId:1367,
          activityId: 2
        }
        wx.showLoading({
          title:'加载中...',
          mask:true
        })
         WXAJAX.POST(data,'','/activity/commitOrder')
        .then((data, code) => {
           console.log(data)
           wx.requestPayment({
              timeStamp: data.timeStamp,
              nonceStr: data.nonce_str,
              package: 'prepay_id=' + data.prepay_id,
              signType: 'MD5',
              paySign: data.paySign,
              success(res) {
                console.log(res);
                wx.hideLoading();
                than.isShowTips = true
              },
              fail(err) {
                console.log(err);
                if (err.errMsg === 'requestPayment:fail cancel') {
                  wx.showToast({
                    title: '支付已取消',
                    icon: 'none'
                  });
                } else {
                  wx.showToast({
                    title: '支付失败',
                    icon: 'none'
                  });
                }
              }
            });
          })
        .catch(err => {
          console.log(err)
          wx.hideLoading();
          wx.showToast({
            title: err.message,
            duration: 2000,
            icon: "none"
          });
        });
      },
      balance(){
        this.isShowConfirm=true;
      },
      visit(){
        wx.navigateTo({
          url: "../companyPack/visitlist/main"
        });
      },
      toMyPushEffect(){
        wx.navigateTo({
          url: "../companyPack/mypusheffect/main"
        });
      },
      toPushEffect(){
        wx.navigateTo({
          url: "../companyPack/pusheffect/main"
        });
      },
      toAward() {
        wx.navigateTo({
          url: "/pages/burse/burse"
        });
      },
      myshare() {
        wx.navigateTo({
          url: "../companyPack/myshare/main"
        });
      },
      makeWx() {
        let v = this;
        wx.setClipboardData({
          data: '17721872191',
          success: function(res) {
            wx.getClipboardData({
              success: function(res) {
                wx.showToast({
                  title: '复制成功'
                })
                v.isShowCourse = true;
              }
            })
          }
        })
      },
      inits() { //获取数据
        wx.showLoading();
        // wx.getStorageSync('userId');
        let params = {
          ignore: true,
          cardId: wx.getStorageSync('SELFCARDID'),
        };
        if (!wx.getStorageSync('SELFCARDID')) {
          params = {
            ignore: true,
          };
        }
        console.log(params)
        WXAJAX.POST(params, '', '/businessCard/getCompanyUserInfo').then((data) => {
          wx.hideLoading();
          if (data) {
            this.companyId = data.companyId
            this.cardId = data.cardId
            // wx.setStorageSync('COMPANYID', data.cardId);
            let cardWelcomeSpeech = {
              company: data.companyName,
              user: data.name,
              shareSpeech: data.shareSpeech ? data.shareSpeech : '',
              welcomeSpeech: data.welcomeSpeech ? data.welcomeSpeech : '',
              hint: data.hint ? data.hint : ''
            };
            wx.setStorageSync('cardWelcomeSpeech', cardWelcomeSpeech);
            wx.setStorageSync('cardId', data.cardId);
            this.card_msg = Object.assign({}, data, {
              companyId: data.companyId,
              picchecked: data.logo || '',
              username: data.name || '',
              tel: data.phone || '',
              wx: data.personalWx || '',
              company_wx: data.companyWx || '',
              email: data.email || '',
              post: data.position || '',
              company: data.companyName,
              company_logo: data.companyLogo,
              password: data.password || '',
            });
            this.card_msg.perfectRateRank = data.perfectRateRank ? (data.perfectRateRank * 100).toFixed(0) : 0;
            this.card_msg.browsePhoto = this.card_msg.browsePhoto ? this.card_msg.browsePhoto.split(',') : [];
            console.log(data);
            this.setCurrentCompany(data);
            this.card_msg.browsePhoto.splice(2, 2)
            // 获取机构模块配置信息
            this.findCompanyModuleConfigs(data.companyId);
          } else {
            this.hasCard = false;
          }
        }).catch((err) => {
          console.log(err);
          this.card_msg = {};
          wx.hideLoading();
          this.hasCard = false;
          wx.showToast({
            title: err.message,
            duration: 2000,
            icon: 'none'
          });
        });
      },
      /**
       * 获取机构模块配置信息
       * @param companyId 机构id
       */
      findCompanyModuleConfigs(companyId) {
        WXAJAX.POST({
          companyId: companyId
        }, '', '/companyModuleConfig/findCompanyModuleConfigs').then((data) => {
          if (data) {
            let d = {};
            data.forEach(function(i, k) {
              d[i.moduleName] = i.close;
            });
            wx.setStorageSync('companyModuleConfig', d);
          }
        }).catch((err) => {});
      },
      tocardCase() { //名片夹
        // wx.navigateTo({url:'../cardCase/main'})
        // wx.navigateTo({url: '../orderLists/main'})
      },
      createCode() {

        WXAJAX.POST({
          cardId: this.currentCompany.cardId,
        }, '', '/businessCard/getWxTwoCode').then((data) => {
          wx.navigateTo({
            url: '/pages/cardCode/main?code=' + data
          })
        }).catch((err) => {
          wx.hideLoading();
          if (err.code == 403) {
            this.nocard_show = true;
          } else {
            wx.showToast({
              title: err.message,
              duration: 2000,
              icon: 'none'
            });
          }
        });
      },
      toRoute(url, query) {
        if (!this.card_msg.cardId) {
          this.nocard_show = true;
        } else {
          if (url == 'cardCase') {
            util.toMiniProgram(`/pages/index/main?companyId=${companyId}&cardId=${cardId}&goType=1`);
          } else {
            wx.navigateTo({
              url: '../' + url + '/main' + (query ? query : '')
            })
          }
        }

      },
      tel() { //拨打电话
        util.MakePhone(this.card_msg.phone || '');
      },
      nocard_btn_tap(str) {
        console.log(str);
        if (str == 'save') {
          this.toCreatePage();
        }
        this.nocard_show = false;
      },
      addWx() { //添加微信
        authSubscribeMessage(this.subscriptionNew);
        let v = this;
        if (v.card_msg.personalWx) {
          wx.setClipboardData({
            data: this.card_msg.personalWx,
            success: function(res) {
              wx.getClipboardData({
                success: function(res) {
                  wx.showToast({
                    title: '复制成功'
                  })
                  v.isShowCourse = true;
                }
              })
            }
          })
        } else {
          wx.showToast({
            title: '还没有添加微信呢！',
            duration: 2000,
            icon: 'none'
          });
        }
      },
      doThumbs() { //点赞
        wx.showLoading();
        WXAJAX.POST({
          cardId: this.currentCompany.cardId,

        }, '', '/businessCard/doThumbs', '', '', 2).then((data) => {

          wx.hideLoading();
          if (this.isThumbs) {
            this.$set(this.card_msg, 'thumbsNum', --this.card_msg.thumbsNum);
          } else {
            this.$set(this.card_msg, 'thumbsNum', ++this.card_msg.thumbsNum);
          }
          this.isThumbs = !this.isThumbs;
        }).catch((err) => {
          wx.hideLoading();
        });
      },
      toMarketing() {
        wx.navigateTo({
          url: '../marketing/marketingList/main'
        })
      },
      openAddr(address) {
        let than = this;
        let author = ''
        wx.showLoading({
          title: "定位中...",
          mask: true
        });
        if (address == "" || !address) {
          wx.showToast({
            title: "请先添加公司地址",
            icon: "none"
          });
          return false;
        }
        WXAJAX.POST({
              address: address
            },
            "",
            "/businessCard/getGps"
          ).then(data => {
            wx.hideLoading();
            let gps = JSON.parse(data).result.location
            console.log(gps)
            let latitude = gps.lat
            let longitude = gps.lng
            wx.openLocation({
              latitude,
              longitude,
              name: address,
              scale: 18,
              success(data) {
                wx.hideLoading();
              },
              fail: function(res) {
                //进入授权页面重新开启定位授权
                wx.hideLoading();
                wx.getSetting({
                  success(e) {
                    author = e.authSetting['scope.userLocation']
                    if (author == false) {
                      than.isShowAuthorize = true;
                      return false
                    }
                  }
                })
              },
            });
          })
          .catch(err => {
            wx.hideLoading();
            uni.showToast({
              title: err,
              icon: 'none'
            })
          })
      },
    },
    computed: {
      ...mapGetters(["currentCompany", "subscriptionNew"])
    },

  }
</script>

<style>
  .toast-box {
      width: 100%;
      height: 100%;
      opacity: 1;
      position: fixed;
      top: 0px;
      left: 0px;
  }


  .toastbg {
      opacity: 0.2;
      background-color: black;
      position: absolute;
      width: 100%;
      min-height: 100vh;
  }

  .showToast {
      position: absolute;
      opacity: 1;
      width: 70%;
      margin-left: 15%;
      margin-top: 40%;
  }

  .toast-title {
      padding-left: 5%;
      background-color: #787878;
      color: white;
      padding-top: 2vh;
      padding-bottom: 2vh;
      border-top-right-radius: 16rpx;
      border-top-left-radius: 16rpx;
  }

  .toast-main {
      padding-top: 2vh;
      padding-bottom: 2vh;
      background-color: white;
      text-align: center;
  }

  .toast-input {
      margin-left: 5%;
      margin-right: 5%;
      border: 1px solid #ddd;
      padding-left: 2vh;
      padding-right: 2vh;
      padding-top: 1vh;
      padding-bottom: 1vh;
  }

  .toast-button {
      display: flex;
  }

  .button1 {
      width: 50%;
  }

  .button2 {
      width: 50%;
  }

  .button1 button {
      width: 100%;
      background-color: white;
      color: red;
      border-radius: 0px;
      border-bottom-left-radius: 16rpx;
  }

  .button2 button{
      width: 100%;
      background-color: white;
      color: black;
      border-radius: 0px;
      border-bottom-right-radius: 16rpx;
  }
  .degree-of-perfection .line-outer {
    position: relative;
    height: 8upx;
    width: 100%;
    background: rgb(245, 245, 245);
    border-radius: 198upx;
    overflow: hidden;
    margin-top: 40upx;
  }

  .degree-of-perfection .line-outer .line {
    height: 8upx;
    width: 0%;
    background: #51CDCB;
  }

  .more-info {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    margin: auto 0;
    height: 40upx;
    width: 30upx;
    background: white;
    box-shadow: 0px 0px 20upx 0px rgba(56, 56, 56, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .more-info .left-img {
    width: 10upx;
    height: 20upx;
  }

  .operation-box {
    margin-left: 130rpx;
    margin-right: 40upx;
    padding-left: 10upx;
  }

  .business_card {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 0 50% 50% 0;
    display: flex;
    align-items: center;
    padding-top: 0;
    width: 140upx;
    box-sizing: border-box;
  }

  .business_card p {
    writing-mode: tb-rl;
  }

  .card_menu {
    position: relative;
  }

  .scroll-list {
    padding: 20upx 40upx 20upx 20upx;
  }

  .scroll-list>div {
    white-space: nowrap;
    box-sizing: border-box;
  }

  .self_introduce {
    height: 214upx;
    transition: .1s;
    overflow: hidden;
  }

  .self_introduce.higher {
    height: auto;
  }

  .output-audio {
    width: 167px;
    height: 40px;
    position: relative;
    margin-right: 22upx;
    padding-left: 40upx;
  }

  .audio::before {
    content: '';
    display: block;
    width: 20upx;
    height: 20upx;
    background: #F5F5F6;
    position: absolute;
    border: 1upx solid #E8E8E8;
    border-radius: 8upx;
    transform: rotate(45deg);
    border-right-width: 0;
    border-top-width: 0;
    top: 0px;
    bottom: 0;
    left: -12upx;
    margin: auto;
  }

  .output-audio .audio {
    padding: 24upx 0 24upx 34upx;
    background: #F5F5F6;
    border: 1upx solid #E8E8E8;
    position: relative;
    height: 34upx;
    border-radius: 10upx;
  }

  .output-audio .audio .ico {
    width: 24upx;
    height: 34upx;
    float: left;
  }

  scroll-view {
    background: #fff;
  }

  .marketing {
    width: 690upx;
    height: 210upx;
    padding: 10upx 0 0upx 0;
    box-sizing: border-box;
    width: 100%;
    background: #FFFFFF;
    display: flex;
    justify-content: center;
  }

  .marketing image {
    width: 100%;
    height: 100%;
  }

  .browsing-history {
    width: 36upx;
  }

  .forward {
    padding: 0 185upx 0 185upx;
  }
</style>
